
library(testthat)
library(blma)
library(tictoc)
library(parallel)

cores <- detectCores()

test_that('comCrime produces correct results liang_g_n_approx', {
	set.seed(2019)
    comCrime <- get_comCrime()
    vy <- comCrime$vy
    mX <- comCrime$mX
    tic('comCrime produces correct results liang_g_n_approx')
    result <- sampler(100000, vy, mX, prior='liang_g_n_approx', modelprior='uniform', cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.9538600000000000,0.8663999999999999,0.3010200000000000,0.8603200000000000,
0.2739900000000000,0.6520100000000000,0.2452700000000000,0.4059500000000000,
0.2718500000000000,0.5524900000000000,0.4741700000000000,0.4384200000000000,
0.2528300000000000,0.2880500000000000,0.1672800000000000,0.1802800000000000,
0.2535500000000000,0.2361300000000000,0.3673300000000000,0.2155200000000000,
0.3723700000000000,0.3060600000000000,0.3894600000000000,0.2676500000000000,
0.2503500000000000,0.2026900000000000,0.2797400000000000,0.2173300000000000,
0.5142900000000000,0.2770800000000000,0.5967800000000000,0.2101600000000000,
0.2054600000000000,0.2550200000000000,0.3879900000000000,0.2186000000000000,
0.2347400000000000,0.2367000000000000,0.2211600000000000,0.8075200000000000,
0.3348100000000000,0.2375300000000000,0.3937300000000000,0.6151000000000000,
0.3144100000000000,0.5036600000000000,0.1942100000000000,0.1982100000000000,
0.8570100000000000,0.9662600000000000,0.9642300000000000,0.1901300000000000,
0.2622900000000000,0.2975600000000000,0.6327100000000000,0.2167800000000000,
0.2998600000000000,0.2616300000000000,0.2390900000000000,0.3415800000000000,
0.2243800000000000,0.4054900000000000,0.3111500000000000,0.3709900000000000,
0.4499700000000000,0.3931500000000000,0.4244300000000000,0.7387100000000000,
0.2458700000000000,0.1697500000000000,0.9404400000000001,0.2874800000000000,
0.4062400000000000,0.1944800000000000,0.2763900000000000,0.1908900000000000,
0.2575600000000000,0.3969000000000000,0.4173400000000000,0.3142900000000000,
0.3471600000000000,0.2080200000000000,0.2342000000000000,0.5782800000000000,
0.3775600000000000,0.1750900000000000,0.7576300000000000,0.2211700000000000,
0.3931900000000000,0.6207300000000000,0.1911100000000000,0.2135000000000000,
0.8650099999999999,0.2473800000000000,0.2201700000000000,0.1823300000000000,
0.1718900000000000,0.1719200000000000,0.9506900000000000
)
, tolerance = 1e-5)
})